package com.ljx.video.oss;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ljx.video.domain.entity.File;
import com.ljx.video.domain.vo.req.FileUploadReq;
import com.ljx.video.mapper.VideoMapper;
import com.ljx.video.util.LocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.InputStream;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2025-02-02  19:16
 */
@Service
public class LocalStrategy implements OssStrategy {

    @Autowired
    private LocalUtil localUtil;

    @Autowired
    private VideoMapper videoMapper;

    @Override
    public void upload(FileUploadReq req) {
        localUtil.uploadChunkToLocal(req);
    }

    @Override
    public InputStream download(Long id, String tsNum) {
        File file = videoMapper.selectById(id);
        return localUtil.download(file.getFileMd5(), tsNum);
    }

    @Override
    public void merge(FileUploadReq req) {
        localUtil.mergeChunksFromLocal(req);
    }
}
